﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Control_DangNhap : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["TenDN"] == null)
        {
            Panel1.Visible = true;
            Panel2.Visible = false;
            Label3.Visible = false;
        }
        else
        {
            Panel1.Visible = false;
            Panel2.Visible = true;
        
        }

    }
    protected void btnDN_Click(object sender, EventArgs e)
    {
        DataTable tb = new DataTable();
        XuLy xl = new XuLy();
        string  query = "select * from thanhvien where Tendn='"+txtTenDN.Text+"' and matkhau='"+txtMatKhau.Text+"'";
        tb = xl.Load(query);
        if (tb.Rows.Count >0)
        {
            Session["TenDN"] = tb.Rows[0]["TenDN"].ToString();
            Label2.Text = Session["TenDN"].ToString();
            Panel1.Visible = false;
            Panel2.Visible = true;
        }
        else
        {
            Label3.Text = "Đăng Nhập Sai! ";
            Label3.Visible = true;
        }
    }
    protected void btnThoat_Click(object sender, EventArgs e)
    {
        Session["TenDN"] = null;
        Panel1.Visible = true;
        Panel2.Visible = false;
    }
}